package com.example.houduan.Service.Impl;

import com.example.houduan.Mapper.DoctorMapper;
import com.example.houduan.Pojo.Doctor;
import com.example.houduan.Service.DoctorService;
import com.example.houduan.Utils.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DoctorServiceImpl implements DoctorService {
    @Autowired
    DoctorMapper doctorMapper;

    @Override
    public List<Doctor> getAllDoctor() {
        return doctorMapper.selectAllDoctor();
    }

    @Override
    public PageModel getDoctorPage(int num,int size) {
        int count=doctorMapper.selectDoctorCount();
        PageModel pm=new PageModel(num,count,size);
        pm.setList(doctorMapper.selectDoctorLimit((num-1)*size,size));
        return pm;
    }

    @Override
    public List<Doctor> getDoctorByConditions(String name,Integer sex, Integer level_id, String hospital) {
        return doctorMapper.selectDoctorByConditions(name,sex,level_id,hospital);
    }


    @Override
    public int addDoctor(Doctor doctor) {
        return doctorMapper.insertDoctor(doctor);
    }

    @Override
    public int updateDoctor(Doctor doctor) {
        return doctorMapper.updateDoctor(doctor);
    }

    @Override
    public int deleteDoctor(int id) {
        return doctorMapper.deleteDoctor(id);
    }
}
